#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# Contains failover benchmarks.
#

now0=`date +'%H%M%S'`

# JVM options.
#JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false -Xms15g -Xmx15g"
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false -ea"

# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
-Xms6g \
-Xmx6g \
-Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
-XX:+UseConcMarkSweepGC \
-XX:+PrintGCDateStamps \
"

#Ignite version
ver="RELEASE-"

# List of default probes.
# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux).
BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe

# Packages where the specified benchmark is searched by reflection mechanism.
BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick

# Flag which indicates to restart the servers before every benchmark execution.
RESTART_SERVERS=true

# Probe point writer class name.
# BENCHMARK_WRITER=

# Comma-separated list of the hosts to run BenchmarkServers on.
SERVER_HOSTS=localhost,localhost

# Comma-separated list of the hosts to run BenchmarkDrivers on.
DRIVER_HOSTS=localhost,localhost

# Remote username.
# REMOTE_USER=

# Number of nodes, used to wait for the specified number of nodes to start.
nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`))

# Space-separated list of Benchmark driver names (required)
dn="\
  IgniteAtomicRetriesBenchmark \
  IgniteAtomicInvokeRetryBenchmark \
  IgniteTransactionalWriteReadBenchmark \
  IgniteTransactionalWriteInvokeBenchmark \
  IgniteTransactionalInvokeRetryBenchmark \
"

# Warmup 1 min.
w=60

# Duration 2h = 2*60*60 = 7200 sec.
d=7200

# Restart delay 10 min = 10 * 60 sec = 600 sec.
rd=600

# Restart sleep 2 min = 120 sec.
rs=120

# Keys rang.
r=100000

# Thread count.
t=128

# Run configuration which contains all benchmarks.
CONFIGS="\
-cfg ${SCRIPT_DIR}/../config/ignite-failover-localhost-config.xml -nn ${nodesNum} -b 1 -w ${w} -d ${d} -rd ${rd} -rs ${rs} -r ${r} -t ${t} --client -sm PRIMARY_SYNC -dn ${dn} -sn IgniteFailoverNode -ds ${ver}failover-1b,\
-cfg ${SCRIPT_DIR}/../config/ignite-failover-localhost-config.xml -nn ${nodesNum} -b 2 -w ${w} -d ${d} -rd ${rd} -rs ${rs} -r ${r} -t ${t} --client -sm PRIMARY_SYNC -dn ${dn} -sn IgniteFailoverNode -ds ${ver}failover-2b,\
"
